﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace SmartMathLibrary.Storage
{
    /// <summary>
    /// This class represents a specialization of an abstract storage. This storage can only
    /// be filled one time, by a parameter of the constructor. After this the data, which the 
    /// storage provides, are read only.
    /// </summary>
    [Serializable]
    public class ReadOnlyPointStorage : AbstractPointStorage
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ReadOnlyPointStorage"/> class.
        /// </summary>
        /// <param name="storage">The storage to clone.</param>
        public ReadOnlyPointStorage(PointStorage storage)
            : base(storage.StorageSize)
        {
            if (storage == (PointStorage) null)
            {
                throw new ArgumentNullException("storage");
            }

            for (int i = 0; i < this.StorageSize; i++)
            {
                this.positionData[i] = storage[i];
            }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ReadOnlyPointStorage"/> class.
        /// </summary>
        /// <param name="storage">The storage to clone.</param>
        public ReadOnlyPointStorage(HighPerformancePointStorage storage)
            : base(storage.StorageSize)
        {
            if (storage == (HighPerformancePointStorage) null)
            {
                throw new ArgumentNullException("storage");
            }

            for (int i = 0; i < this.StorageSize; i++)
            {
                this.positionData[i] = storage[i];
            }
        }
    }
}